namespace hjc {

	export interface IAstarStrategy {
		map: AStarMap;
		calc(from: AStarNode, to: AStarNode): number
	}

	//欧式距离估值法(对角线距离)
	export class DiagonalStrategy implements IAstarStrategy {
		public map: AStarMap;
		public calc(from: AStarNode, to: AStarNode): number {
			let [w, h] = [Math.abs(from.col - to.col), Math.abs(from.row - to.row)];
			return this.map.avgCost * (Math.min(w, h) + this.map.diagCost * Math.abs(w - h));
		}
	}

	//曼哈顿距离估值法(街区距离)
	export class ManhattanStrategy implements IAstarStrategy {
		public map: AStarMap;
		public calc(from: AStarNode, to: AStarNode): number {
			return this.map.avgCost * (Math.abs(from.col - to.col) + Math.abs(from.row - to.row));
		}
	}
}